﻿using MQTTnet.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;

namespace Artizan.Iot.Hub.Mqtt.Server
{
    public class MqttServerService: IMqttServerService, ITransientDependency
    { 
        private readonly IMqttConnectionService _mqttConnectionService;
        private readonly IMqttPublishingService _mqttPublishingService;
        private readonly IMqttSubscriptionService _mqttSubscriptionService;
        private readonly IMqttInternalService _mqttInternalService;
        public MqttServer MqttServer { get; private set; }

        public MqttServerService(
            IMqttConnectionService mqttConnectionService, 
            IMqttPublishingService mqttPublishingService, 
            IMqttSubscriptionService mqttSubscriptionService, 
            IMqttInternalService mqttInternalService)
        {
            _mqttConnectionService = mqttConnectionService;
            _mqttPublishingService = mqttPublishingService;
            _mqttSubscriptionService = mqttSubscriptionService;
            _mqttInternalService = mqttInternalService;
        }


        public void ConfigureMqttService(MqttServer mqttServer)
        {
            MqttServer =  mqttServer;

            _mqttConnectionService.ConfigureMqttServer(mqttServer);
            _mqttPublishingService.ConfigureMqttServer(mqttServer);
            _mqttSubscriptionService.ConfigureMqttServer(mqttServer);
            _mqttInternalService.ConfigureMqttServer(mqttServer);
        }

    
    }
}
